import itk
import vtk
import connect2
import myImageViewer
import pythonRegistration as pr

def Test_Blend2():
    """
    Test overlaying 2 images
    """

    blender=vtk.vtkImageBlend()
    itk2vtk1=connect2.itk2vtk()
    itk2vtk2=connect2.itk2vtk()
    view=myImageViewer.Viewer
    lut = vtk.vtkLookupTable()
    colors=vtk.vtkImageMapToColors()


    lut.SetTableRange(0,2000)
    lut.SetHueRange(0,0)
    lut.SetSaturationRange(1,0)
    lut.SetValueRange(1,1)
    lut.Build()

    pose=(0,0,0,0,0,10)
    reg.SetPose(pose)
    reg.GenerateMovingImage()

    itk2vtk1.SetInput(reg.fixedImage)
    itk2vtk2.SetInput(reg.movingImage)

    blender.SetInput(0,itk2vtk1.GetOutput())
    blender.SetInput(1,itk2vtk2.GetOutput())

    blender.SetBlendMode(0)

    blender.SetOpacity(0,0.2)
    blender.SetOpacity(1,0.4)
    #view(blender.GetOutput())

    colors.SetInput(blender.GetOutput())
    colors.SetLookupTable(lut)

    imageActor = vtk.vtkImageActor()
    imageActor.SetInput(colors.GetOutput())

    ren=vtk.vtkRenderer()
    renWin=vtk.vtkRenderWindow()
    renWin.AddRenderer(ren)

    ren.AddActor(imageActor)
    renWin.SetSize(512,512)
    #ren.SetBackground(0.1, 0.2, 0.4)
    renWin.Render()

if __name__ == "__main__":
    Test_TestBlend2()
